<!DOCTYPE html>
<html lang="en" class="app"
      xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://rbac.rbacshiro.com"
>
<head th:include="template/top"></head>
<body>
<section class="vbox">
    <header th:include="template/header" class="bg-dark dk header navbar navbar-fixed-top-xs"></header>
    <section>
        <section class="hbox stretch">
            <!-- .aside -->
            <aside th:include="template/menu" class="bg-dark lter aside-md hidden-print" id="nav"></aside>
            <!-- /.aside -->
            <section id="content">
                <section class="vbox">
                    <section class="scrollable padder">
                        <ul class="breadcrumb no-border no-radius b-b b-light pull-in">
                            <li><a href="index.html"><i class="fa fa-home"></i> 首页</a></li>
                            <li class="active">个人中心</li>
                            <li class="active">个人信息</li>
                        </ul>
                        <section class="scrollable wrapper">
                            <div class="row">
                                <div class="col-lg-12">
                                    <section class="panel panel-default" id="auth_profile">
                                        <header class="panel-heading bg-danger lt no-border">
                                            <div class="clearfix">
                                                <a href="#" class="pull-left thumb avatar b-3x m-r">
                                                    <img src="admin/avatar" class="img-circle" style="width: 58px;height: 58px;" id="avatar">
                                                </a>
                                                <a href="#" class="pull-left thumb avatar b-3x m-r" style="z-index: 1000;position: absolute;left: 30px;" title="点击切换头像">
                                                    <div id="pictureBtn"></div>
                                                </a>
                                                <div class="clear">
                                                    <div class="h3 m-t-xs m-b-xs text-white"> {{profile.username}} </div>
                                                    <a href="profile-chpasswd.html"><small class="text-muted">修改密码</small></a>
                                                </div>
                                            </div>
                                        </header>
                                        <div class="list-group no-radius alt">
                                            {{if profile.phone}}
                                            <a class="list-group-item" href="tel:{{profile.phone}}"> 电话： {{profile.phone}} </a>
                                            {{/if}}
                                            {{if profile.registerTime}}
                                            <a class="list-group-item"> 注册时间： {{profile.registerTime}} </a>
                                            {{/if}}
                                            {{if profile.lastLoginIp}}
                                            <a class="list-group-item"> 登录IP： {{profile.lastLoginIp}} </a>
                                            {{/if}}
                                            {{if profile.lastLoginTime}}
                                            <a class="list-group-item"> 登录时间： {{profile.lastLoginTime}} </a>
                                            {{/if}}
                                        </div>
                                    </section>
                                </div>
                            </div>
                        </section>
                </section>
                </section>
                <a href="#" class="hide nav-off-screen-block" data-toggle="class:nav-off-screen" data-target="#nav"></a> </section>
                <aside class="bg-light lter b-l aside-md hide" id="notes">
                    <div class="wrapper">Notification</div>
                </aside>
        </section>
    </section>
</section>
<script th:replace="template/js"></script>
<script src="js/charts/easypiechart/jquery.easy-pie-chart.js" cache="false"></script>
<script src="js/charts/sparkline/jquery.sparkline.min.js" cache="false"></script>
<script src="uploadify/jquery.uploadify.min.js"></script>

<script src="menu.js"></script>
<script>
    $(document).on('click', '.setting', function () {
        if($(this).hasClass("phone")) {
            layer.open("setting")
        }
    });
    var authProfileTemplate = loadArtTemplate("auth_profile");
    commonAjax({
        url:'admin/profile',
        async:false,
        success:function (result) {
            var render = template.compile(authProfileTemplate);
            var html = render({
                profile:result.data
            });
            $('#auth_profile').html(html);
        }
    });
    $('#pictureBtn').uploadify({
        swf: 'uploadify/uploadify.swf',
        uploader : 'admin/profile/avatar',
        buttonText:'',
        multi:false,
        height:58,
        width:58,
        onUploadError:function (file, errorCode, errorMsg, errorString) {
            layer.alert("上传失败");
        },
        onUploadSuccess:function (file, data, response) {
            commonAjax({
                url:'admin/avatar/save',
                data:{
                    avatar:$.parseJSON(data).data
                },
                dataType:'json',
                success:function(result){
                    if(result.success) {
                        window.location.reload();
                    } else {
                        layer.alert("保存失败!");
                    }
                }
            });
        }
    });
</script>
</body>
</html>